package com.v.partitionerAndwritable;


import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;

import java.io.IOException;


public class FlowMap extends Mapper<LongWritable, Text, FlowBean,Text > {

    private FlowBean KIn = new FlowBean();
    private Text KOut = new Text();

    @Override
    protected void map(LongWritable key, Text value, Mapper<LongWritable, Text, FlowBean, Text>.Context context) throws IOException, InterruptedException {
        //1.转换类型
        String line = value.toString();

        //切割
        String[] fields = line.split("\t");

        //封装
        KOut.set(fields[0]); // 手机号是输出
        KIn.setUpFlow(Long.parseLong(fields[1]));
        KIn.setDownFlow(Long.parseLong(fields[2]));
        KIn.setSumFlow();

        //写出
        context.write(KIn,KOut);


    }
}
